package com.gengdan.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gengdan.bean.SampleStorage;
import com.gengdan.service.SampleStorageService;
import com.gengdan.util.Page;
import com.gengdan.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * @author Sun Mingshan
 * @Description 样本入库表Controller
 * @date 2020/4/19 20:25
 */
@Controller
public class SampleStorageController {
    @Autowired
    private SampleStorageService sampleStorageService;

    @Autowired
    private HashMap<String,Object> hashMap;
    /***
    * @Description 查询所有样本入库信息【捐献者】
    * @param
    * @Return java.util.HashMap
    * @Author Sun Mingshan
    * @Date 2020/4/19 21:19
    **/
    @RequestMapping("/select_sampleStorage")
    @ResponseBody
    public HashMap selectAllSampleStorage(SampleStorage sampleStorage){
        hashMap =  sampleStorageService.selectSampleStorage(sampleStorage.getUserIdOperator());
        return hashMap;
    }

    /***
    * @Description 查询入库记录【入库员】
    * @param page
    * @Return java.util.HashMap
    * @Author Sun Mingshan
    * @Date 2020/5/10 11:10
    **/
    @RequestMapping("/selectSampleStorageR2")
    @ResponseBody
    public HashMap selectSampleStorageR2(Page page){
        hashMap =  sampleStorageService.selectSampleStorageR2(page);
        return hashMap;
    }
    /***
    * @Description 删除入库记录【入库员】
    * @param
    * @Return java.util.HashMap
    * @Author Sun Mingshan
    * @Date 2020/5/10 12:22
    **/
    @RequestMapping("/delSampleStorageR2")
    @ResponseBody
    public HashMap delSampleStorageR2(@RequestBody Map map){
        hashMap =  sampleStorageService.deleteSampleStorageR2(map);
        return hashMap;
    }

    @RequestMapping("/selectSampleStorageR2ByKey")
    @ResponseBody
    public HashMap selectSampleStorageR2ByKey(Page page,String keyWord){
        System.out.println(page.getStart());
        hashMap =  sampleStorageService.selectSampleStorageR2ByKey(page,keyWord);

        return hashMap;
    }
    /**
     * 以下测试
     */
    /* 【入库分配位置】 - 1.显示容器信息 */
    @RequestMapping("/selectContainerName")
    @ResponseBody
    public HashMap selectContainerName(){
        hashMap = sampleStorageService.selectContainerName();
        return hashMap;
    }
    /*<!--【入库分配位置】 - 2.存储区*/
    @RequestMapping("/selectStorageArea")
    @ResponseBody
    HashMap<String,Object> selectStorageArea(String conName){
        hashMap = sampleStorageService.selectStorageArea(conName);
        return hashMap;
    }
    /*【入库分配位置】 - 3.冻存盒 */
    @RequestMapping("/selectHoleLocCode")
    @ResponseBody
    HashMap<String,Object> selectHoleLocCode(String holeLocCode){
        hashMap = sampleStorageService.selectHoleLocCode(holeLocCode);
        return hashMap;
    }
    /* 【入库分配位置】 - 4.显示容器信息 */
    @RequestMapping("/insertSampleStorage")
    @ResponseBody
    public HashMap insertSampleStorage(@RequestBody Map map){
        hashMap = sampleStorageService.insertSampleStorage(map);
        return hashMap;
    }
    /*【登记入库】 - 删除样本处理信息 */
    @RequestMapping("/deleteSampleProc")
    @ResponseBody
    HashMap<String,Object>  deleteSampleProc(@RequestBody Map map){
        hashMap = sampleStorageService.deleteSampleProc(map);
        return hashMap;
    }
    /*【登记入库】 - 高级检索 */
    @RequestMapping("/selectSampleProcR2ByKey")
    @ResponseBody
    HashMap<String,Object>  selectSampleProcR2ByKey(Page page,String keyWord){
        hashMap = sampleStorageService.selectSampleProcR2ByKey(page,keyWord);
        return hashMap;
    }

    /*【登记入库】 - 分配位置 */
    @RequestMapping("/updateSampleProc")
    @ResponseBody
    HashMap<String,Object>  updateSampleProc(int countryCode){
        hashMap = sampleStorageService.updateSampleProc(countryCode);
        return hashMap;
    }

    /*【登记入库】 - 查找信息 */
    @RequestMapping("/selectSampleProcR2")
    @ResponseBody
    HashMap<String,Object>  selectSampleProcR2(Page page){
        hashMap = sampleStorageService.selectSampleStorageR2(page);
        return hashMap;
    }

}
